//
//  TotalViewController.m
//  JingJing
//
//  Created by User on 15/10/10.
//  Copyright © 2015年 JingJing. All rights reserved.
//

#import "TotalViewController.h"
#import "HomeViewController.h"
#import "MagazineController.h"
#import "ProductsAndServicesViewController.h"
#import "OwnerViewController.h"

@interface TotalViewController ()

@end

@implementation TotalViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    HomeViewController *homeViewCon = [[HomeViewController alloc]init];
    homeViewCon.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"首页"  image:[[UIImage imageNamed:@"tab_menu1_nor"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]selectedImage:[[UIImage imageNamed:@"tab_menu1_sel"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]];
    
    MagazineController *magazineCon = [[MagazineController alloc]init];
    magazineCon.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"杂志"  image:[[UIImage imageNamed:@"tab_menu2_nor"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tab_menu2_sel"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]];
    UINavigationController *magazineNav = [[UINavigationController alloc]initWithRootViewController:magazineCon];
    
    ProductsAndServicesViewController *productAndServicsVC  = [[ProductsAndServicesViewController alloc]init];
    productAndServicsVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"活动&服务" image:[[UIImage imageNamed:@"tab_menu3_nor"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tab_menu3_sel"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    OwnerViewController *ownerViewCon = [[OwnerViewController alloc]init];
    ownerViewCon.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"个人中心"  image:[[UIImage imageNamed:@"tab_menu4_nor"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ]selectedImage:[[UIImage imageNamed:@"tab_menu4_sel"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    self.viewControllers = @[homeViewCon, magazineNav, productAndServicsVC, ownerViewCon];
    
    
    [UITabBar appearance].barTintColor = [UIColor grayColor];
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]} forState:UIControlStateSelected];
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateNormal];
    
    /**
     *  Navigation的外观设置
     */
    // 设置整个项目所有item的主题样式
    // 设置普通状态
    [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],
                                   NSFontAttributeName:[UIFont systemFontOfSize:17]
                                   } forState:UIControlStateNormal];
    
    [[UINavigationBar appearance] setTitleTextAttributes:@{
                                     NSForegroundColorAttributeName:[UIColor whiteColor],
                                     NSFontAttributeName: [UIFont fontWithName:@"Helvetica-Bold" size:20],
                                     //                                    NSFontAttributeName: [UIFont fontWithName:@"STHeiti_light" size:17],
                                     }];

    [[UINavigationBar appearance] setBackgroundImage:[self imageWithColor:kColorOrangeMain size:CGSizeMake(1, 1)] forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearance] setShadowImage:[[UIImage alloc]init]];

    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
}

- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size
{
    CGRect rect = CGRectMake(0, 0, size.width, size.height);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context,color.CGColor);
    CGContextFillRect(context, rect);
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return img;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
